package gtgold;

import java.awt.*;
import javax.swing.*;

/**
 * Main GUI container that holds the JFrame which will hold everything else.
 * 
 * There's probably a more optimal way to organize the GUI, but this is just a
 * quick and dirty way to link everything together.
 * 
 * @author jo
 */
public class OregonTrail
{
	/** Standard VGA resolution */
	public static Dimension VGA = new Dimension(640, 480);

	/** Main housing JFrame */
	public static JFrame frame;

	/** All JPanel's should be added into here */
	public static Container contentPane;

	// JPanel instances
	public static JPanel titleScreen;
	public static JPanel configScreen;
	public static JPanel mainScreen;
	
	// MenuBar
	public static MenuBar menuBar;

	/**
	 * Main driver method
	 * 
	 * @param args
	 *            command line arguments
	 */
	public static void main(String[] args)
	{
		// Obtain OS default look-and-feel theme
		try
		{
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception e)
		{
		}

		// Set up JFrame
		frame = new JFrame("Oregon Trail GOLD");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setResizable(false);

		menuBar = new MenuBar();
		frame.setJMenuBar(menuBar.menuBar);
		
		// Set up first screen
		contentPane = frame.getContentPane();
		titleScreen();
		
		// Display game
		frame.pack();
		frame.setVisible(true);

		// DO NOTHING ELSE!!
	}

	public static void titleScreen()
	{
		titleScreen = new TitleScreen();
		contentPane.add(titleScreen);
		
		frame.pack();
	}
	
	/**
	 * Display the party configuration screen
	 */
	public static void configScreen()
	{
		titleScreen.setVisible(false);
		titleScreen = null;
		
		contentPane.removeAll();
		
		configScreen = new ConfigScreen();
		contentPane.add(configScreen);
		
		frame.pack();
	}

	/**
	 * Display the main game screen
	 * 
	 * @param screen
	 *            JPanel of main screen to display in main frame
	 */
	public static void mainScreen(JPanel screen)
	{
		mainScreen = screen;

		if (titleScreen != null) titleScreen.setVisible(false);
		titleScreen = null;
		if (configScreen != null) configScreen.setVisible(false);
		configScreen = null;
		
		contentPane.removeAll();

		contentPane.add(mainScreen);
		
		frame.pack();
	}

	public static void reset()
	{
		contentPane.removeAll();
		titleScreen();
	}
}
